﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Testcraft.Physics
{
    class PhysicsBody : IVolume
    {
        private float velocityCapSquared = 0.1f * 0.1f;
        private float velocityCap = 0.1f;
        private Vector3 pendingForces;

        public bool InRest { get; set; }
        public bool IsStatic { get; set; }
        public Vector3 Position { get; set; }
        public BoundingBox Bounds { get; set; }
        public BoundingBox PreviousBounds { get; set; }
        public Vector3 NetForces { get; set; }
        public Vector3 Velocity { get; set; }
        public float Weight { get; set; }

        public float VelocityCap
        {
            get { return velocityCap; }
            set
            {
                this.velocityCap = value;
                
            }
        }

        internal float VelocityCapSquared
        {
            get { return velocityCapSquared; }
        }

        public void ApplyPendingForce(Vector3 force)
        {
            if (force != Vector3.Zero)
            {
                this.InRest = false;
                this.pendingForces += force;
            }
        }

        public void ClearPendingForces()
        {
            this.pendingForces = Vector3.Zero;
        }

        public void CommitPendingForces()
        {
            this.NetForces += this.pendingForces;
            this.ClearPendingForces();
        }
    }
}
